<?php

class DrillCategoryController extends GxController {

  public $pageTitle = "Editor";
  public $backurl;
  public $view_css = "/css/views/drillcategory.css";


	public function actionView($id) {
    $this->allowUsers(Array(),Array());
    $this->pageTitle .= " : \"".$this->loadModel($id, 'drill-category')->id."\" Details";
    $this->layout = '/layouts/main';
    $this->backurl = "admin";	
		$this->render('view', array(
			'model' => $this->loadModel($id, 'DrillCategory'),
		));
	}

	public function actionCreate() {
		$this->allowUsers(Array(),Array());
		$model = new DrillCategory;


		if (isset($_POST['DrillCategory'])) {
			$model->setAttributes($_POST['DrillCategory']);

			if ($model->save()) {
				if (Yii::app()->getRequest()->getIsAjaxRequest())
					Yii::app()->end();
				else
					$this->redirect(array('view', 'id' => $model->id));
			}
		}
    $this->pageTitle .= " : New";
    $this->layout = '/layouts/main';
    $this->backurl = "admin";
		$this->render('create', array( 'model' => $model));
	}

	public function actionUpdate($id) {
		$this->allowUsers(Array(),Array());
		$model = $this->loadModel($id, 'DrillCategory');


		if (isset($_POST['DrillCategory'])) {
			$model->setAttributes($_POST['DrillCategory']);

			if ($model->save()) {
				$this->redirect(array('view', 'id' => $model->id));
			}
		}
		$this->pageTitle .= " : \"".$model->id."\"";
    $this->layout = '/layouts/main';
    $this->backurl = "admin";
		$this->render('update', array(
				'model' => $model,
				));
	}

	public function actionDelete($id) {
	  $this->allowUsers(Array(),Array());
		if (Yii::app()->getRequest()->getIsPostRequest()) {
			$this->loadModel($id, 'DrillCategory')->delete();

			if (!Yii::app()->getRequest()->getIsAjaxRequest())
				$this->redirect(array('admin'));
		} else
			throw new CHttpException(400, Yii::t('app', 'Your request is invalid.'));
	}

	public function actionIndex() {
				$this->allowUsers(Array(),Array());
				$this->redirect(array('admin'));
	}


	public function actionAdmin() {
		$this->allowUsers(Array(),Array());
		$model = new DrillCategory('search');
		$model->unsetAttributes();

    if (isset($_GET['pageSize'])) {
        Yii::app()->user->setState('pageSize',(int)$_GET['pageSize']);
        unset($_GET['pageSize']);
    }
  
		if (isset($_GET['DrillCategory']))
			$model->setAttributes($_GET['DrillCategory']);

    $this->layout = '/layouts/main';
		$this->render('admin', array(
			'model' => $model,
		));
	}


    public function actionPdfExport() {

        $this->allowUsers(Array(),Array());
        $model = new DrillCategory('search');
        $this->layout = 'none';
        $this->render('pdfexport', array(
            'model' => $model,
        ));
    }

    
    public function actionExcelExport() {

        $this->allowUsers(Array(),Array());
        $model = new DrillCategory('search');
        $this->layout = 'none';
        $this->render('excelexport', array(
            'model' => $model,
        ));
    }
    


}